package com.yb.java.singleton;

/**
 * @program: design-pattern
 * @description: 懒汉式单例模式，线程安全。每次调用getInstance()都需要同步，能够在多线程中使用。同步需要增加额外的开销，一般不建议用
 * @author: Mr.Bo
 * @create: 2021-04-25 20:43
 **/
public class LazyManSingleton {

    private static LazyManSingleton instance;

    private LazyManSingleton(){}

    public static synchronized LazyManSingleton getInstance(){
        if (instance == null){
            instance = new LazyManSingleton();
        }
        return instance;
    }
}
